package china.accountinghelper.database;

import java.util.Map;

import com.xdroid.base.SQLiteDALBase;

import android.content.ContentValues;
import android.database.Cursor;
import china.wc.tallyhelper.model.ModelExpenseDetail;

/**
 * 操作ModelExpenseDetail类的SQLiteDatabaseDAL类
 * 
 * 
 * 
 * @author 王超
 * 
 */
public class SQLiteDALModelExpenseDetail extends SQLiteDALBase<ModelExpenseDetail> {

	public SQLiteDALModelExpenseDetail(Class<ModelExpenseDetail> pModelClass) {
		super(pModelClass);
	}


	@Override
	protected ContentValues toContentValues(ModelExpenseDetail pModelExpenseDetail) {
		Map<String, String> _FieldColumnMap = getFieldColumnMap();
		ContentValues _ContentValues = new ContentValues();
		
		for (String _FieldName : _FieldColumnMap.keySet()) {
			if ("mExpenseID".equals(_FieldName)) {
				_ContentValues.put(_FieldColumnMap.get(_FieldName), pModelExpenseDetail.getExpenseID());
			} else if ("mConsumerID".equals(_FieldName)) {
				_ContentValues.put(_FieldColumnMap.get(_FieldName), pModelExpenseDetail.getConsumerID());
			} else if ("mMoney".equals(_FieldName)) {
				_ContentValues.put(_FieldColumnMap.get(_FieldName), pModelExpenseDetail.getMoney1());
			}
		}
		
		return _ContentValues;
	}


	@Override
	protected ModelExpenseDetail toModel(Cursor pCursor) {
		ModelExpenseDetail _ModelExpenseDetail = new ModelExpenseDetail();
		
		_ModelExpenseDetail.setID(pCursor.getLong(pCursor.getColumnIndexOrThrow(getPrimaryColumnName())));
		_ModelExpenseDetail.setExpenseID(pCursor.getLong(pCursor.getColumnIndexOrThrow(getFieldColumnMap().get("mExpenseID"))));
		_ModelExpenseDetail.setConsumerID(pCursor.getLong(pCursor.getColumnIndexOrThrow(getFieldColumnMap().get("mConsumerID"))));
		_ModelExpenseDetail.setMoney(pCursor.getLong(pCursor.getColumnIndexOrThrow(getFieldColumnMap().get("mMoney"))));
		
		return _ModelExpenseDetail;
	}


}
